<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Spoon</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Distributing instrumentation tests to all your Androids">
    <link href="static/bootstrap-combined.min.css" rel="stylesheet">
    <link href="static/app.css" rel="stylesheet">
    <link href="static/app-theme.css" rel="stylesheet">
    <link href="http://fonts.googleapis.com/css?family=Roboto:400,300italic,100,100italic,300" rel="stylesheet" type="text/css">
    <!--[if lt IE 9]><script src="static/html5shiv.min.js"></script><![endif]-->
  </head>
  <body data-target=".content-nav">
    <header>
      <div class="container">
        <div class="row">
          <div class="span5">
            <h1>Spoon</h1>
          </div>
          <div class="span7">
            <menu>
              <ul>
                <li><a href="#download" class="menu download">Download <span class="version-tag">Latest</span></a></li>
                <li><a href="http://github.com/square/spoon" data-title="View GitHub Project" class="menu github"><img src="static/icon-github.png" alt="GitHub"/></a></li>
                <li><a href="http://square.github.io/" data-title="Square Open Source Portal" class="menu square"><img src="static/icon-square.png" alt="Square"/></a></li>
              </ul>
            </menu>
          </div>
      </div>
    </header>
    <section id="subtitle">
      <div class="container">
        <div class="row">
          <div class="span12">
            <h2>Distributing <strong>instrumentation tests</strong> to all your Androids</h2>
          </div>
        </div>
      </div>
    </section>
    <section id="body">
      <div class="container">
        <div class="row">
          <div class="span9">
            <h3 id="introduction">Introduction</h3>
            <p>Android's ever-expanding ecosystem of devices creates a unique challenge to testing applications. Spoon aims to simplify this task by distributing instrumentation test execution and displaying the results in a meaningful way.</p>
            <p>Instead of attempting to be a new form of testing, Spoon makes existing instrumentation tests more useful. Using the application APK and instrumentation APK, Spoon runs the tests on multiple devices simultaneously. Once all tests have completed, a static HTML summary is generated with detailed information about each device and test.</p>
            <p><img src="static/example_main.png" alt="Example output"></p>
            <p>With the high-level output you can immediately see whether or not a test failure is specific to a single device or all devices. This view is designed to be displayed on a dedicated monitor or TV.</p>
            <img src="static/device_cluster.png" class="pull-right">
            <p>Spoon will run on all targets which are visible to <code>adb devices</code>. Plug in multiple different phones and tablets, start different configurations of emulators, or use some combination of both!</p>
            <p>The greater diversity of the targets in use, the more useful the output will be in visualizing your applications.</p>

            <h4 id="device-view">Device View</h4>
            <p>The device view outlines the results of each test one a single device. This is useful for tracking down device-specific failures of individual tests.</p>
            <p><img src="static/example_device_view.png" alt="Example device view"></p>

            <h4 id="test-view">Test View</h4>
            <p>The test view shows the results of a single test across all of the devices it was executed on.</p>
            <p><img src="static/example_test_view.png" alt="Example test view"></p>

            <h4 id="screenshots">Screenshots</h4>
            <p>In addition to simply running instrumentation tests, Spoon has the ability to snap screenshots at key points during your tests which are then included in the output. This allows for visual inspection of test executions across different devices.</p>
            <p>Taking screenshots requires that you include the <code>spoon-client</code> JAR in your instrumentation app. In your tests call the <code>screenshot</code> method with a human-readable tag.</p>
            <pre class="prettyprint">Spoon.screenshot(activity, "initial_state");
/* Normal test code... */
Spoon.screenshot(activity, "after_login");</pre>
            <p>The tag specified will be used to identify and compare screenshots taken across multiple test runs.</p>
            <p>Screenshots are displayed in order in both the device view and the test view:</p>
            <p><img src="static/example_screenshots.png" alt="Sample output with screenshots"></p>
            <p>You can also view each test's screenshots as an animated GIF to gauge the actual sequence of interaction.</p>

            <h3 id="download">Download</h3>
            <p><a href="https://search.maven.org/classic/remote_content?g=com.squareup.spoon&a=spoon-runner&v=LATEST&c=jar-with-dependencies" class="dl runner-version-href">&darr; <span class="version-tag">Latest</span> Runner JAR</a> <a href="https://search.maven.org/classic/remote_content?g=com.squareup.spoon&a=spoon-client&v=LATEST" class="dl client-version-href">&darr; <span class="version-tag">Latest</span> Client JAR</a></p>

            <p>The source code to the runner, client library, and sample applications as well as this website is <a href="http://github.com/square/spoon">available on GitHub</a>.</p>

            <h4>Maven</h4>
            <p>If you are using Maven for compilation you can declare the screenshot library as a dependency.</p>
            <pre class="prettyprint">&lt;dependency>
  &lt;groupId>com.squareup.spoon&lt;/groupId>
  &lt;artifactId>spoon-client&lt;/artifactId>
  &lt;version><span class="version pln"><em>(insert latest version)</em></span>&lt;/version>
&lt;/dependency></pre>

            <h4 id="sample">Sample</h4>
            <p>Included with Spoon is a sample application and instrumentation tests to demonstrate both the usage as well as provide an example of the output.</p>
            <p>The sample shows a simple login screen and an ordering wizard run on a few devices. The application and tests have been constructed so that some have broken styles or will fail on various devices. This was done to give a better idea of what the real-world output looks like.</p>
            <p><a href="sample/index.html">View sample execution output &raquo;</a></p>

            <h3 id="execution">Execution</h3>
            <p>Spoon was designed to be run both as a standalone tool or directly as part of your build system.</p>

            <h4 id="cli">Command Line</h4>
            <p>You can run Spoon as a standalone tool with your application and instrumentation APKs.</p>
            <pre>java -jar spoon-runner-<span class="version"><em>(insert latest version)</em></span>-jar-with-dependencies.jar \
    --apk example-app.apk \
    --test-apk example-tests.apk</pre>
            <p>By default the output will be placed in a <code>spoon-output/</code> folder of the current directory. You can control additional parameters of the execution using other flags.</p>
            <pre>Options:
    --apk               Application APK
    --fail-on-failure   Non-zero exit code on failure
    --output            Output path
    --sdk               Path to Android SDK
    --test-apk          Test application APK
    --title             Execution title
    --class-name        Test class name to run (fully-qualified)
    --method-name       Test method name to run (must also use --class-name)</pre>
    --no-animations     Disable animated gif generation
    --size              Only run test methods annotated by testSize (small, medium, large)
    --adb-timeout       Set maximum execution time per test in seconds (10min default)
            <h4 id="maven">Maven</h4>
            <p>If you are using Maven for compilation, a plugin is provided for easy execution. Declare the plugin in the <code>pom.xml</code> for the instrumentation test module.</p>
            <pre class="prettyprint">&lt;plugin>
  &lt;groupId>com.squareup.spoon&lt;/groupId>
  &lt;artifactId>spoon-maven-plugin&lt;/artifactId>
  &lt;version><span class="version pln"><em>(insert latest version)</em></span>&lt;/version>
&lt;/plugin></pre>
            <p>The plugin will look for an <code>apk</code> dependency for the corresponding application. Typically this is specified in parallel with the <code>jar</code> dependency on the application.</p>
            <pre class="prettyprint">&lt;dependency>
  &lt;groupId>com.example&lt;/groupId>
  &lt;artifactId>example-app&lt;/artifactId>
  &lt;version>${project.version}&lt;/version>
  &lt;type>jar&lt;/type>
  &lt;scope>provided&lt;/scope>
&lt;/dependency>
&lt;dependency>
  &lt;groupId>com.example&lt;/groupId>
  &lt;artifactId>example-app&lt;/artifactId>
  &lt;version>${project.version}&lt;/version>
  &lt;type>apk&lt;/type>
  &lt;scope>provided&lt;/scope>
&lt;/dependency></pre>
            <p>You can invoke the plugin by running <code>mvn spoon:run</code>. The execution result will be placed in the <code>target/spoon-output/</code> folder.  If you want to specify a test class to run, add <code>-Dspoon.test.class=fully.qualified.ClassName</code>. If you only want to run a single test in that class, add <code>-Dspoon.test.method=testAllTheThings.</code></p>
            <p>For a working example see the sample application and instrumentation tests in the <code>spoon-sample/</code> folder.</p>

            <h3 id="contributing">Contributing</h3>
            <p>If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.</p>
            <p>When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running <code>mvn clean verify</code>.</p>
            <p>Before your code can be accepted into the project you must also sign the <a href="http://squ.re/sign-the-cla">Individual Contributor License Agreement (CLA)</a>.</p>

            <h3 id="license">License</h3>
            <pre>Copyright 2013 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>
          </div>
          <div class="span3">
            <div class="content-nav" data-spy="affix" data-offset-top="80">
              <ul class="nav nav-tabs nav-stacked primary">
                <li><a href="#introduction">Introduction</a></li>
                <li><a href="#download">Download</a></li>
                <li><a href="#execution">Execution</a></li>
                <li><a href="#contributing">Contributing</a></li>
                <li><a href="#license">License</a></li>
              </ul>
              <ul class="nav nav-pills nav-stacked secondary">
                <li><a href="http://stackoverflow.com/questions/tagged/spoon?sort=active">StackOverflow</a></li>
                <li><a href="sample/index.html">Sample Output</a></li>
              </ul>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="span12 logo">
            <a href="https://squareup.com"><img src="static/logo-square.png" alt="Square, Inc."/></a>
          </div>
        </div>
      </div>
    </section>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="static/bootstrap.min.js"></script>
    <script src="static/jquery.smooth-scroll.min.js"></script>
    <script src="static/jquery-maven-artifact.min.js"></script>
    <script src="static/prettify.js"></script>
    <script type="text/javascript">
      $(function() {
        // Syntax highlight code blocks.
        prettyPrint();

        // Spy on scroll position for real-time updating of current section.
        $('body').scrollspy();

        // Use smooth-scroll for internal links.
        $('a').smoothScroll();

        // Enable tooltips on the header nav image items.
        $('.menu').tooltip({
          placement: 'bottom',
          trigger: 'hover',
          container: 'body',
          delay: {
            show: 500,
            hide: 0
          }
        });

        // TODO support classifiers!
        // $.fn.artifactVersion('com.squareup.spoon', 'spoon-runner', function(version, url) {
        //   $('.runner-version').text('v' + version);
        //   $('.runner-href').attr('href', url);
        // });
        $.fn.artifactVersion('com.squareup.spoon', 'spoon-client', function(version, url) {
          $('.version').text(version);
          $('.version-tag').text('v' + version);
          $('.client-version-href').attr('href', url);
        });
      });
    </script>
  </body>
</html>
